package com.xssn.fjnd.content.api;

import com.xssn.fjnd.content.req.PhotoREQ;
import com.xssn.fjnd.content.req.VideoREQ;
import com.xssn.fjnd.content.service.IPhotoService;
import com.xssn.util.base.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

@Api(value = "演出图片管理API接口", description = "演出图片管理API接口，不需要通过身份认证就可以访问下面的接口")
@RestController
@RequestMapping("/api/photo")
public class ApiPhotoController {

    @Autowired
    private IPhotoService photoService;

    @ApiOperation("根据图片标题和类型查询图片分页列表接口")
    @PostMapping("/search") // localhost:8001/content/photo/search
    public Result search(@RequestBody PhotoREQ req) {
        return photoService.publicPage(req);
    }


    @ApiOperation("查询演出图片详情接口")
    @ApiImplicitParam(name = "id", value = "图片ID", required = true)
    @GetMapping("/{id}")
    public Result view(@PathVariable String id) {

        return Result.ok(photoService.getById(id));
    }

    @ApiOperation("更新演出图片浏览次数")
    @ApiImplicitParam(name = "id", value = "演出图片ID", required = true)
    @PutMapping("/viewCount/{id}") // /api/photo/viewCount/{id}
    public Result updateViewCount(@PathVariable("id") String id) {
        return photoService.updateViewCount(id);
    }

}
